import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import getters from './getters'
import createPersistedstate from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    user
  },
  getters,
  plugins: [
    createPersistedstate({
      key: 'vuexRoleList', 
      reducer (val) {
        return {
          roleList: val.user.roleList,
          areaCode: val.user.areaCode,
          roleId: val.user.roleId,
        }
      }
    })
  ]
})

export default store
